pp108 : deleteCheckedRows() Method

deleteCheckedRows() Method


This method removes all the checked rows. The row is visibly removed from the XGrid and the corresponding rowData is also removed from the XML data. Therefore, this method is only usable for non-transactional data.

Syntax


xgridId.deleteCheckedRows( )

Parameters


No parameters.

Return Value


No return value.

Remarks


To be able to check or uncheck the passed row, you must set theuseCheckboxesproperty totrue. This method executes theoncheckrowevent.

This method is not suitable for transactional data, as therowDatanode is removed. Transactional data requires an<old>/<new>structure, and usually involves the setting of attributes to therowDatanode.

Especial consideration must be given to large datasets when used in combination with thecheckAllRows()method; for example, deleting 10,000 rows is time-consuming.

Example


The following example demonstrates the use of this method.

First some non-transactional data is generated and used to fill the XGrid. By checking rows manually and invoking thedeleteCheckedRowsbutton, the correspondingrowDatanodes are deleted.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html >
  <head>
         <meta content="Web Generator" name="Generator"/>
         <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
         <title>deleteCheckedRows</title>
<script src="/cordys/wcp/application.js"></script>
<script type="cordys/xml" id="fieldsXML">
     <data></data>
</script> 
<script type="cordys/xml" id="newNode">
     <fields>
             <field1></field1>
             <field2></field2>
     </fields>
</script>
<script>
 var XMLNode;
/*creates sample data to fill XGrid*/
function fillXGrid()
   {
       var numberOfRows = parseInt(document.getElementById("noRows").value);
       XMLNode = cordys.cloneXMLDocument(fieldsXML.XMLDocument);
       var dataNode = cordys.selectXMLNode(XMLNode,".//*[local-name()='data']");
       for (var i=0 ; i<(numberOfRows) ; i++ )
           {
               var newRow = cordys.cloneXMLDocument(newNode.XMLDocument).firstChild;
               cordys.setTextContent(cordys.selectXMLNode(newRow,".//*[local-name()='field1']"), "field1_" + i);
               cordys.setTextContent(cordys.selectXMLNode(newRow,".//*[local-name()='field2']"), i);
              // newRow.selectSingleNode("field2").text = i;
              // dataNode.appendChild(newRow);
              cordys.appendXMLNode(newRow,dataNode) 
           }
        myGrid.bindData( XMLNode );
    }
function deleteCheckedRows()
   {
        myGrid.deleteCheckedRows();
   }
function showData()
   {
        application.notify(cordys.getXML(XMLNode));
   }
</script>
</head>
<body>
    noRows<input value="10" id="noRows"  style="width:50px">
    <button onclick="fillXGrid()">fill XGrid</button>
    <button onclick="deleteCheckedRows()">deleteCheckedRows</button>
    <button onclick="showData()">show data</button>
    <br /><br />
    <div cordysType="wcp.library.ui.XGrid"
         id="myGrid"
         xpathRowData = "data/fields"
         xpathBusinessObject = "."
         style="width:400;height:200">
         <div id="field1" ref="field1" fieldType="input">field1</div>
         <div id="field2" ref="field2" fieldType="output">field2</div>
     </div>
</body>
</html>

See Also


xgrid